/*
** server.h for zappy in /home/chris/Rendu/B4/UNIX/zappy
** 
** Made by christophe lecointe
** Login   <lecoin_c@epitech.net>
** 
** Started on  Fri May 25 13:09:57 2012 christophe lecointe
** Last update Thu May 31 12:01:33 2012 christophe lecointe
*/

#ifndef __SERVER__
#define __SERVER__

#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>

#define MAX_TABLE_SIZE	1024
#define HASHDIV		6


// struct stockant les parametres recupere dans l'input.
// (Ajouter dans cette struct la liste de joueurs).

typedef struct s_params
{
   unsigned int	width;
   unsigned int	heigh;
   unsigned int	nb_clients;
   int		time;
   unsigned int	port;
}		t_params;

typedef struct s_objet
{
/*different type de pierre*/
   unsigned int	linemate;
   unsigned int	deraumere;
   unsigned int sibur;
   unsigned int	mendiane;
   unsigned int	phiras;
   unsigned int	thystame;
/* la nourriture*/
   unsigned int	food;
}		t_objet;

typedef struct		s_player
{
  pid_t			id;
  unsigned int		lvl;
  unsigned int		posX;
  unsigned int		posY;
  t_objet		inventaire;
  struct s_player	*next;
}			t_player;

typedef struct	s_ids
{
  pid_t		id;
  struct s_ids	*next;
}		t_ids;

typedef struct	s_case
{
  t_objet	obj;
  t_ids		*players;
}		t_case;

typedef struct s_map
{
  unsigned int	width;
  unsigned int	heigh;
  unsigned int	nb_players;
  t_case	**map;
}		t_map;

typedef t_player	** t_pTable;

// struct englobant les autres structures.
typedef struct s_data
{
   t_pTable	pList;
   t_map	map;
   t_params	params;
}		t_data;




/* hashtables.c */

void		initTable(t_pTable *);
int		addPlayer(t_pTable *, t_player *);
t_player	*getPlayer(t_pTable *, pid_t);
void		removePlayer(t_pTable *, t_player *);

/* hashtables_utils.c */

pid_t		getPrevList(t_pTable, pid_t);

/* list_manager.c */
void			add_in_list(t_player *list, t_player *to_add);
t_player		*remove_from_list(t_player *list, t_player *to_del);
t_player		*get_player_from_list(t_player *list, pid_t to_find);

#endif
